package day14;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author oldliu
 * @since 1.0
 */
public class SocketTest {
    public static void main(String[] args) {
        try {
            ServerSocket st=new ServerSocket(8888);
            while (true){
                System.out.println("有人脸上了");
                Socket s=st.accept();//
                System.out.println(s.getPort());
                System.out.println("local port:"+s.getLocalPort());
                InputStream in = s.getInputStream();
                int ch=-1;//aviable()
                while ((ch=in.read())!=-1){
                    System.out.print((char)ch);
                }

            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
